CC=gcc
SDLC=`sdl-config --cflags`
SDLO=`sdl-config --libs`
CFLAGS= -Wall -W -Werror -pedantic -ansi
MAIN= main.c
SDLF=sdl.c
RPN=rpn.c

3DF=3d.c
3DFLAGS=-I /usr/include/GL/ -L /usr/include/GL/ -lGL -lGLU -lX11 -lm
3DFLAGSBIS=-L /usr/include/GL/ -lGL -lGLU -lX11 -lm -I /usr/include/GL/

OCAMLOPT=ocamlopt
SDL= -I +sdl
LABLGTK= -I +lablGL -I +lablgtk2 -I +labltk
LABLGL= -I +lablGL

SDL_LIB= bigarray.cmxa sdl.cmxa sdlloader.cmxa
LABLGTK_LIB= lablgl.cmxa labltk.cmxa lablgtk.cmxa gtkInit.cmx togl.cmxa
LABLGL_LIB= lablgl.cmxa lablglut.cmxa str.cmxa

SDL_MLI= bigarray.cma sdl.cma sdlloader.cma
LABLGTK_MLI= lablgl.cma labltk.cma lablgtk.cma gtkInit.cma togl.cma
LABLGL_MLI= lablgl.cma lablglut.cma str.cma

all::

	${CC} ${SDLC} -c ${SDLF}
	${CC} ${SDLO} -o sdl sdl.o

	${CC} ${SDLC} ${3DFLAGS} -c ${3DF}
	${CC} ${SDLO} ${3DFLAGS} -o 3d 3d.o

	${OCAMLOPT} ${SDL} ${LABLGTK} ${SDL_LIB} ${LABLGTK_LIB} -w -26 -w s -o interface interface.ml
	./interface

sdl: 
	${CC} ${SDLC} -c ${SDLF}
	${CC} ${SDLO} -o sdl sdl.o

sdlbis:
	${CC} -I /usr/include/SDL /usr/include/SDL/SDL_ttf.h -lSDL_ttf -std=c99 -o sdlbis sdl.c -lSDL

interface: interface.ml
	${OCAMLOPT} ${SDL} ${LABLGTK} ${SDL_LIB} ${LABLGTK_LIB} -w -26 -w s -o interface interface.ml

trid:
	${CC} ${CFLAGS} ${SDLC} ${3DFLAGS} -c ${3DF}
	${CC} ${CFlAGS} ${SDLO} ${3DFLAGS} -o 3d 3d.o

tdbis:
	${CC} ${3DFLAGS} /usr/include/SDL /usr/include/SDL/SDL_ttf.h -lSDL_ttf -std=c99 -o sdlbis sdl.c -lSDL -c ${3DF}
	${CC} ${SDLO} ${3DFLAGS} -o 3dbis 3d.o
	./3dbis

clean:
	rm -f main sdl sdlbis rpn interface 3d
	rm -f *.o
	rm -f \#*
	rm -f *~ *.cm?
	rm -f *.bmp
#END
